// custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    list: [{
      "pagePath": "/pages/home/home",
      "text": "首页",
      "icon": "home-o"
    }, {
      "pagePath": "/pages/car/car",
      "text": "购物车",
      "icon": 'cart-circle-o'
    }, {
      "pagePath": "/pages/user/user",
      "text": "用户",
      "icon": "friends-o"
    }],
    active: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      this.setData({
        active: event.detail
      });

      // 切换tabbar
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })

    },
  }
})